package cn.message.web;

import cn.itcast.pojo.earnings;
import cn.itcast.pojo.recharge;
import cn.itcast.util.OutputStringController;
import cn.message.service.IEarningsService;
import cn.message.service.IRechargeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 收益记录控制器
 * @author 郭智超
 * @create 2020-04-06 10:31
 */

@Slf4j
@RestController
@RequestMapping(value="/dhn/message",produces="text/html;charset=UTF-8")
public class EarningsController {

    @Resource
    private IEarningsService earningsService;

    @Resource
    OutputStringController osc;

    @ResponseBody
    @RequestMapping("/getAllEarnings")
    public String getAllEarnings(@RequestBody Map<String,String> map){
        String results = "";

        Map<String, Object> resultMap = earningsService.getAllEarnings(map);

        //获取所有符合条件的账户列表信息
        Object earningsList = resultMap.get("earningsList");
        //获取符合查询条件的总记录条数
        int count = (int)resultMap.get("count");

        if(earningsList == null){
            results = osc.resultFailure("no", "");
            log.debug("查询所有账户信息失败");
        }
        else {
            results = osc.resultSuccess("yes",earningsList, count);
            log.debug("查询所有账户信息成功");
        }
        return results;
    }
}
